<template>
	<view :data-theme="theme">
		<view class='commission-details'>
			<view class='sign-record'>
				<block v-for="(item,index) in recordList" :key="index" v-if="recordList.length>0">
					<view class='list borderPad'>
						<view class='item'>
							<view class='data'>{{item.month}}</view>
							<view class='listn borRadius14'>
								<block v-for="(child,indexn) in item.list" :key="indexn">
									<view class='itemn acea-row row-between-wrapper' @click="hanldInvoice(child)">
										<view style="width: 70%;">
                      <view class='name line1'>{{ child.cardholder }}</view>
											<view class='name line1' v-if="child.invoiceStatus=='0'">
												开票状态:未开票
											</view>
											<!-- <view class='name line1' v-if="child.invoiceStatus=='1'">
												开票状态:开票中
											</view> -->
                      <view class='name line1' v-else>
												开票状态:已开票
											</view>
											
											<view>{{child.createTime}}</view>
										</view>
										<view class='num font_color'>{{child.closingPrice}}</view>
									</view>
								</block>
							</view>
						</view>
					</view>
				</block>
				<view v-if="recordList.length == 0">
					<emptyPage title='暂无开票记录~' :imgSrc="urlDomain+'crmebimage/presets/noJilu.png'"></emptyPage>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	// +----------------------------------------------------------------------
	// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
	// +----------------------------------------------------------------------
	// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
	// +----------------------------------------------------------------------
	// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
	// +----------------------------------------------------------------------
	// | Author: CRMEB Team <admin@crmeb.com>
	// +----------------------------------------------------------------------
	import {
		getCommissionInfo,
		getClosingRecordApi,
	} from '@/api/user.js';
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	import emptyPage from '@/components/emptyPage.vue'
	import {
		setThemeColor
	} from '@/utils/setTheme.js'
	const app = getApp();
	export default {
		components: {
			emptyPage
		},
		filters: {
			statusFilter(status) {
				const statusMap = {
					'2': '已拒绝',
					'0': '待审核',
					'1': '审核成功',
				}
				return statusMap[status]
			}
		},
		data() {
			return {
				urlDomain: this.$Cache.get("imgHost"),
				name: '',
				type: 0,
				page: 1,
				limit: 20,
				recordList: [],
				recordType: 0,
				loadend: false,
				extractCount: 0,
				theme: app.globalData.theme,
				commissionCount: 0,
				bgColor: '#e93323'
			};
		},
		computed: mapGetters(['isLogin']),
		onLoad(options) {
      if(!this.isLogin){
        toLogin();
      }
			let that = this;
			that.bgColor = setThemeColor();
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: that.bgColor,
			});
		},
		onShow: function() {
      uni.setNavigationBarTitle({
        title: "开票记录"
      });
      this.name = '开票总额';
      this.recordType = 4;
      this.getList();
		},
		methods: {
			hanldInvoice(item) {
				uni.navigateTo({
					url: '/pages/users/user_settlement_money/userInvoice?id='+item.id,
				})
			},
			getList: function() {
				let that = this;
				let recordList = that.recordList;
				let recordListNew = [];
				if (that.loadend == true) return;
				getClosingRecordApi({
					page: that.page,
					limit: that.limit
				}).then(res => {
					that.page = that.page + 1;
					let len = that.page > res.data.totalPage;
					let recordListData = res.data || [];
					recordListNew = recordList.concat(recordListData);
					that.loadend = len;
					that.$set(that, 'recordList', recordListNew);
				});
			},
		},
		onReachBottom: function() {
      this.getList();
		}
	}
</script>

<style scoped lang="scss">
	.commission-details .promoterHeader .headerCon .money {
		font-size: 36rpx;
	}

	.promoterHeader {
		@include main_bg_color(theme);
	}

	.commission-details .promoterHeader .headerCon .money .num {
		font-family: 'Guildford Pro';
	}

	.font_color {
		color: #E93323 !important;
	}
</style>